home *** CD-ROM | disk | FTP | other *** search
- From: envbvs@epb2.lbl.gov (Brian V. Smith)
- Newsgroups: comp.sources.x
- Subject: v06i086: xfig 2.0, Patch6, Part06/06
- Message-ID: <134792@sun.Eng.Sun.COM>
- Date: 24 Apr 90 22:29:40 GMT
- Approved: argv@sun.com
-
- Submitted-by: envbvs@epb2.lbl.gov (Brian V. Smith)
- Posting-number: Volume 6, Issue 86
- Archive-name: xfig2/patch6.6
- Patch-To: xfig2: Volume 6, Issues 9-24, 34-36, 50-56
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 6 (of 6)."
- # Contents: change.c.diff
- # Wrapped by envbvs@epb2.lbl.gov on Tue Apr 24 11:56:49 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'change.c.diff' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'change.c.diff'\"
- else
- echo shar: Extracting \"'change.c.diff'\" \(39291 characters\)
- sed "s/^X//" >'change.c.diff' <<'END_OF_FILE'
- X*** change.c.old Tue Apr 24 11:48:09 1990
- X--- change.c Thu Apr 19 12:18:08 1990
- X***************
- X*** 0 ****
- X--- 1,1420 ----
- X+ /*
- X+ * FIG : Facility for Interactive Generation of figures
- X+ *
- X+ * Created March 1990 by Jon Tombs <jon@uk.ac.oxford.robots>
- X+ * This is my first X program please excuse the style, probably
- X+ * only works with X11R4
- X+ * Last Update 1st April 1989
- X+ *
- X+ * %W% %G%
- X+ *
- X+ * Based on the file of the same name from the fig-fs distribution:
- X+ *
- X+ * Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
- X+ * January 1985.
- X+ * 1st revision : Aug 1985.
- X+ *
- X+ * Change function implemented by Frank Schmuck (schmuck@svax.cs.cornell.edu)
- X+ * July 1988.
- X+ */
- X+
- X+ #include "fig.h"
- X+ #include "resources.h"
- X+ #include "func.h"
- X+ #include "object.h"
- X+ #include "paintop.h"
- X+ #include "font.h"
- X+ #include "psfonts.h"
- X+
- X+ #define TOLERANCE 7
- X+ #define min(a, b) (((a) < (b)) ? (a) : (b))
- X+ #define max(a, b) (((a) > (b)) ? (a) : (b))
- X+
- X+ extern char *sprintf();
- X+ extern char *panel_get_value();
- X+ extern Widget make_popup_menu();
- X+ extern void toggle();
- X+
- X+ extern (*canvas_kbd_proc)();
- X+ extern (*canvas_locmove_proc)();
- X+ extern (*canvas_leftbut_proc)();
- X+ extern (*canvas_middlebut_proc)();
- X+ extern (*canvas_rightbut_proc)();
- X+ extern (*return_proc)();
- X+ extern null_proc();
- X+ extern set_popupmenu();
- X+
- X+ extern F_text *text_search();
- X+
- X+ extern int foreground_color, background_color;
- X+ extern Pixmap font_menu_bitmaps[];
- X+ extern int *font_sel; /* pointer to store font selected from popup */
- X+ extern Widget image_widget; /* which widget to store image of font in */
- X+
- X+ extern change_text();
- X+ extern change_item();
- X+ extern change_depth_up();
- X+ extern change_depth_down();
- X+ extern void Quit();
- X+ extern void new_generic_values();
- X+ static void line_style_select();
- X+ static void text_adjust_select();
- X+ static Widget popup, form;
- X+ static Widget below, beside;
- X+
- X+ extern F_line *line_search(), *copy_line();
- X+ extern F_arc *arc_search(), *copy_arc();
- X+ extern F_ellipse *ellipse_search(), *copy_ellipse();
- X+ extern F_text *text_search(), *copy_text();
- X+ extern F_spline *spline_search(), *copy_spline();
- X+ extern F_compound *compound_search();
- X+ extern F_arrow *forward_arrow(), *backward_arrow();
- X+ extern F_compound objects;
- X+
- X+ extern int SIDERULER_WIDTH, PANL_WID;
- X+ extern int RHS_PANL;
- X+ extern float cur_dashlength;
- X+ extern float cur_dotgap;
- X+
- X+ init_change();
- X+ done_compound();
- X+ done_line();
- X+ done_text();
- X+ done_arc();
- X+ done_ellipse();
- X+ done_spline();
- X+
- X+ static F_line *new_line;
- X+ static F_ellipse *new_ellipse;
- X+ static F_text *new_text;
- X+ static F_spline *new_spline;
- X+ static F_arc *new_arc;
- X+ static F_compound *new_compound;
- X+
- X+ static Widget label;
- X+ static Widget thickness_panel;
- X+ static Widget color_panel;
- X+ static Widget depth_panel;
- X+ static Widget angle_panel;
- X+ static Widget adjust_panel;
- X+ static Widget area_fill_panel;
- X+ static Widget fill_pct_label;
- X+ static Widget style_panel;
- X+ static Widget style_val_panel;
- X+ static Widget for_arrow_panel;
- X+ static Widget back_arrow_panel;
- X+ static Widget text_panel;
- X+ static Widget x1_panel, y1_panel;
- X+ static Widget x2_panel, y2_panel;
- X+ static Widget x3_panel, y3_panel;
- X+ static Widget font_panel;
- X+ static Widget font_size_panel;
- X+ static Widget filled_panel;
- X+ static Widget radius;
- X+ static Widget entry, menu, adjust_menu;
- X+ static Widget but1;
- X+
- X+ Arg args[12];
- X+
- X+
- X+ #define MAX_POINTS 100
- X+ static Widget px_panel[MAX_POINTS];
- X+ static Widget py_panel[MAX_POINTS];
- X+
- X+ static int ellipse_flag;
- X+ static int no_fill_flag;
- X+ static int (*done_proc)();
- X+ static int button_result;
- X+ static int text_adjust;
- X+ static int new_font;
- X+ #define CANCEL 0
- X+ #define DONE 1
- X+ #define APPLY 2
- X+
- X+ static struct {
- X+ int thickness;
- X+ int color;
- X+ int depth;
- X+ int style;
- X+ float style_val;
- X+ int pen;
- X+ int area_fill;
- X+ int for_arrow;
- X+ int back_arrow;
- X+ } generic_vals;
- X+
- X+ #define put_generic_vals(x) \
- X+ generic_vals.thickness = x->thickness; \
- X+ generic_vals.color = x->color; \
- X+ generic_vals.depth = x->depth; \
- X+ generic_vals.style = x->style; \
- X+ generic_vals.style_val = x->style_val; \
- X+ generic_vals.pen = x->pen; \
- X+ generic_vals.area_fill = x->area_fill
- X+
- X+ #define get_generic_vals(x) \
- X+ new_generic_values(NULL, NULL); \
- X+ x->thickness = generic_vals.thickness; \
- X+ x->color = generic_vals.color; \
- X+ x->depth = generic_vals.depth; \
- X+ x->style = generic_vals.style; \
- X+ x->style_val = generic_vals.style_val; \
- X+ x->pen = generic_vals.pen; \
- X+ x->area_fill = generic_vals.area_fill
- X+
- X+ #define put_generic_arrows(x) \
- X+ generic_vals.for_arrow = (x->for_arrow != NULL); \
- X+ generic_vals.back_arrow = (x->back_arrow != NULL)
- X+
- X+ #define get_generic_arrows(x) \
- X+ if (x->for_arrow) \
- X+ free((char*)x->for_arrow); \
- X+ if (x->back_arrow) \
- X+ free((char*)x->back_arrow); \
- X+ x->for_arrow = (generic_vals.for_arrow)? forward_arrow(): NULL; \
- X+ x->back_arrow = (generic_vals.back_arrow)? backward_arrow(): NULL
- X+
- X+
- X+ change_item_selected()
- X+ {
- X+ canvas_kbd_proc = null_proc;
- X+ canvas_locmove_proc = null_proc;
- X+ canvas_leftbut_proc = change_item;
- X+ canvas_middlebut_proc = null_proc;
- X+ canvas_rightbut_proc = set_popupmenu;
- X+ return_proc = change_item_selected;
- X+ set_cursor(&pick9_cursor);
- X+ reset_action_on();
- X+ }
- X+
- X+
- X+ change_item(x, y)
- X+ int x, y;
- X+ {
- X+ extern F_line *line_search();
- X+ extern F_arc *arc_search();
- X+ extern F_ellipse *ellipse_search();
- X+ extern F_text *text_search();
- X+ extern F_spline *spline_search();
- X+ extern F_compound *compound_search();
- X+ F_line *l;
- X+ F_arc *a;
- X+ F_ellipse *e;
- X+ F_text *t;
- X+ F_spline *s;
- X+ F_compound *c;
- X+ int dummy;
- X+
- X+
- X+ if ((l = line_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL) {
- X+ make_window_line(l);
- X+ }
- X+ else if ((t = text_search(x, y)) != NULL) {
- X+ make_window_text(t);
- X+ }
- X+ else if ((e = ellipse_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL){
- X+ make_window_ellipse(e);
- X+ }
- X+ else if ((a = arc_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL){
- X+ make_window_arc(a);
- X+ }
- X+ else if ((s = spline_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL) {
- X+ make_window_spline(s);
- X+ }
- X+ else if ((c = compound_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL)
- X+ make_window_compound(c);
- X+ else
- X+ return;
- X+
- X+ XtPopup(popup, XtGrabExclusive);
- X+ }
- X+
- X+
- X+ make_window_compound(c)
- X+ F_compound *c;
- X+ {
- X+ generic_window("COMPOUND", "Cannot be changed!", done_compound, 0, 0);
- X+ }
- X+
- X+ done_compound()
- X+ {
- X+ if (button_result != APPLY) {
- X+ clean_up();
- X+ show_pointmarker();
- X+ }
- X+ }
- X+
- X+ make_window_line(l)
- X+ F_line *l;
- X+ {
- X+ struct f_point p1, p2;
- X+
- X+ new_line = copy_line(l);
- X+ new_line->next = l;
- X+ put_generic_vals(new_line);
- X+ switch (new_line->type) {
- X+ case T_POLYLINE:
- X+ put_generic_arrows(new_line);
- X+ generic_window("POLYLINE", "Polyline", done_line, 1, 1);
- X+ points_panel(new_line->points, 0);
- X+ break;
- X+ case T_POLYGON:
- X+ put_generic_arrows(new_line);
- X+ generic_window("POLYLINE", "Polygon", done_line, 1, 1);
- X+ points_panel(new_line->points, 1);
- X+ break;
- X+ case T_BOX:
- X+ generic_window("POLYLINE", "Box", done_line, 1, 0);
- X+ p1 = *new_line->points;
- X+ p2 = *new_line->points->next->next;
- X+ xy_panel(p1.x, p1.y, "Top Left", &x1_panel, &y1_panel);
- X+ xy_panel(p2.x, p2.y, "Bottom Right", &x2_panel, &y2_panel);
- X+ break;
- X+ case T_ARC_BOX:
- X+ generic_window("POLYLINE", "ArcBox", done_line, 1, 0);
- X+ p1 = *new_line->points;
- X+ p2 = *new_line->points->next->next;
- X+ xy_panel(p1.x, p1.y, "Top Left", &x1_panel, &y1_panel);
- X+ xy_panel(p2.x, p2.y, "Bottom Right", &x2_panel, &y2_panel);
- X+ int_panel(new_line->radius, "Radius:", &radius);
- X+ break;
- X+ }
- X+ }
- X+
- X+ static
- X+ get_new_line_values()
- X+ {
- X+ struct f_point p1, p2, *p;
- X+
- X+ get_generic_vals(new_line);
- X+ if ((new_line->type != T_BOX) && (new_line->type != T_ARC_BOX)) {
- X+ get_generic_arrows(new_line);
- X+ get_points(new_line->points, (new_line->type == T_POLYGON));
- X+ }
- X+ else {
- X+ p1.x = atoi(panel_get_value(x1_panel));
- X+ p1.y = atoi(panel_get_value(y1_panel));
- X+ p2.x = atoi(panel_get_value(x2_panel));
- X+ p2.y = atoi(panel_get_value(y2_panel));
- X+ p = new_line->points;
- X+ p->x = p1.x; p->y = p1.y; p = p->next;
- X+ p->x = p2.x; p->y = p1.y; p = p->next;
- X+ p->x = p2.x; p->y = p2.y; p = p->next;
- X+ p->x = p1.x; p->y = p2.y; p = p->next;
- X+ p->x = p1.x; p->y = p1.y;
- X+ if (new_line->type == T_ARC_BOX)
- X+ new_line->radius = atoi(panel_get_value(radius));
- X+ }
- X+ }
- X+
- X+ done_line()
- X+ {
- X+ F_line *old_line;
- X+
- X+
- X+ draw_line(new_line, ERASE);
- X+ old_line = new_line->next;
- X+ switch (button_result) {
- X+ case APPLY:
- X+ get_new_line_values();
- X+ draw_line(new_line, PAINT);
- X+ break;
- X+ case DONE:
- X+ clean_up();
- X+ get_new_line_values();
- X+ set_action_object(F_CHANGE, O_POLYLINE);
- X+ new_line->next = NULL;
- X+ delete_line(&objects.lines, old_line);
- X+ insert_line(&objects.lines, new_line);
- X+ set_latestline(old_line);
- X+ old_line->next = new_line;
- X+ draw_line(new_line, PAINT);
- X+ show_pointmarker();
- X+ set_modifiedflag();
- X+ break;
- X+ case CANCEL:
- X+ clean_up();
- X+ new_line->next = NULL;
- X+ free_line(&new_line);
- X+ draw_line(old_line, PAINT);
- X+ show_pointmarker();
- X+ break;
- X+ }
- X+
- X+ }
- X+
- X+ #define round(x) ((int) ((x) + ((x >= 0)? 0.5: -0.5)))
- X+
- X+ make_window_text(t)
- X+ F_text *t;
- X+ {
- X+ PIX_FONT temp_font;
- X+ int i,cw;
- X+ static char * adjust_item_names[] = {
- X+ "Left Justified ", "Centered ", "Right Justified"};
- X+
- X+ new_text = copy_text(t);
- X+ new_text->next = t;
- X+ generic_window("TEXT", "", done_text, 0, 0);
- X+ #ifdef notdef
- X+ subtype_panel = panel_create_item(change_panel, PANEL_CYCLE,
- X+ PANEL_LABEL_X, ATTR_COL(2),
- X+ PANEL_LABEL_Y, ATTR_ROW(2),
- X+ PANEL_VALUE_X, ATTR_COL(20),
- X+ PANEL_VALUE_Y, ATTR_ROW(2),
- X+ PANEL_LABEL_STRING, "Text alignment:",
- X+ PANEL_CHOICE_STRINGS, "left justified", "center justified",
- X+ "right justified", 0,
- X+ PANEL_VALUE, new_text->type,
- X+ 0);
- X+ font_panel = panel_create_item(change_panel, PANEL_CYCLE,
- X+ PANEL_LABEL_X, ATTR_COL(2),
- X+ PANEL_LABEL_Y, ATTR_ROW(3),
- X+ PANEL_VALUE_X, ATTR_COL(20),
- X+ PANEL_VALUE_Y, ATTR_ROW(3),
- X+ PANEL_LABEL_STRING, "Font:",
- X+ PANEL_CHOICE_STRINGS, "default", "roman",
- X+ "bold", "italic",
- X+ "modern", "typewriter", 0,
- X+ PANEL_VALUE, new_text->font,
- X+ 0);
- X+ #endif
- X+
- X+ text_adjust = new_text->type; /* get current justification */
- X+ new_font = new_text->font; /* get current font */
- X+
- X+ int_panel(new_text->size, "Size:", &font_size_panel);
- X+ int_panel(new_text->color, "Color:", &color_panel);
- X+ int_panel(new_text->depth, "Depth:", &depth_panel);
- X+ int_panel(round(180/M_PI * new_text->angle), "Angle:", &angle_panel);
- X+
- X+ /* make text justification menu */
- X+
- X+ XtSetArg(args[0], XtNfromVert, below);
- X+ adjust_panel = XtCreateManagedWidget(
- X+ adjust_item_names[text_adjust], menuButtonWidgetClass,
- X+ form, args, ONE);
- X+ below = adjust_panel;
- X+ adjust_menu = make_popup_menu(adjust_item_names, XtNumber(adjust_item_names),
- X+ adjust_panel, text_adjust_select);
- X+
- X+ xy_panel(new_text->base_x,new_text->base_y, "Origin:", &x1_panel, &y1_panel);
- X+ image_panel(font_menu_bitmaps[new_text->font], "Font:", &font_panel);
- X+ str_panel(new_text->cstring, "Text:", &text_panel);
- X+ }
- X+
- X+ static
- X+ get_new_text_values()
- X+ {
- X+ char *s;
- X+
- X+ PR_SIZE size;
- X+
- X+ #ifdef notdef
- X+ new_text->type = atoi(panel_get_value(subtype_panel));
- X+ new_text->font = atoi(panel_get_value(font_panel));
- X+ #else
- X+ new_text->type = text_adjust;
- X+ new_text->font = new_font;
- X+ #endif
- X+ new_text->size = atoi(panel_get_value(font_size_panel));
- X+ if (new_text->size < 1)
- X+ {
- X+ new_text->size = 1;
- X+ panel_set_value(font_size_panel, "1");
- X+ }
- X+ new_text->color = atoi(panel_get_value(color_panel));
- X+ new_text->depth = atoi(panel_get_value(depth_panel));
- X+ new_text->angle = M_PI/180*atoi(panel_get_value(angle_panel));
- X+ new_text->base_x = atoi(panel_get_value(x1_panel));
- X+ new_text->base_y = atoi(panel_get_value(y1_panel));
- X+ if (new_text->cstring)
- X+ cfree(new_text->cstring);
- X+ s = panel_get_value(text_panel);
- X+ new_text->cstring = (char *) calloc((unsigned)(strlen(s)+1), sizeof(char));
- X+ strcpy(new_text->cstring, s);
- X+ size = pf_textwidth(new_text->font, new_text->size, strlen(s), s);
- X+ new_text->height = size.y;
- X+ new_text->length = size.x;
- X+ }
- X+
- X+ done_text()
- X+ {
- X+ F_text *old_text;
- X+
- X+ draw_text(new_text, INV_PAINT);
- X+ old_text = new_text->next;
- X+ switch (button_result) {
- X+ case APPLY:
- X+ get_new_text_values();
- X+ break;
- X+ case DONE:
- X+ clean_up();
- X+ get_new_text_values();
- X+ set_action_object(F_CHANGE, O_TEXT);
- X+ new_text->next = NULL;
- X+ delete_text(&objects.texts, old_text);
- X+ insert_text(&objects.texts, new_text);
- X+ set_latesttext(old_text);
- X+ old_text->next = new_text;
- X+
- X+ show_pointmarker();
- X+ set_modifiedflag();
- X+ break;
- X+ case CANCEL:
- X+ clean_up();
- X+ new_text->next = NULL;
- X+ free_text(&new_text);
- X+ new_text = old_text;
- X+
- X+ show_pointmarker();
- X+ break;
- X+ }
- X+ draw_text(new_text, PAINT);
- X+ }
- X+
- X+ make_window_ellipse(e)
- X+ F_ellipse *e;
- X+ {
- X+ char *s1, *s2;
- X+
- X+ new_ellipse = copy_ellipse(e);
- X+ new_ellipse->next = e;
- X+ switch (new_ellipse->type) {
- X+ case T_ELLIPSE_BY_RAD:
- X+ s1 = "ELLIPSE";
- X+ s2 = "specified by radius";
- X+ ellipse_flag = 1;
- X+ break;
- X+ case T_ELLIPSE_BY_DIA:
- X+ s1 = "ELLIPSE";
- X+ s2 = "specified by diameter";
- X+ ellipse_flag = 1;
- X+ break;
- X+ case T_CIRCLE_BY_RAD:
- X+ s1 = "CIRCLE";
- X+ s2 = "specified by radius";
- X+ ellipse_flag = 0;
- X+ break;
- X+ case T_CIRCLE_BY_DIA:
- X+ s1 = "CIRCLE";
- X+ s2 = "specified by diameter";
- X+ ellipse_flag = 0;
- X+ break;
- X+ }
- X+ put_generic_vals(new_ellipse);
- X+ generic_window(s1, s2, done_ellipse, 1, 0);
- X+ int_panel(round(180/M_PI * new_ellipse->angle), "Angle:", &angle_panel);
- X+
- X+ if (ellipse_flag) {
- X+ f_pos_panel(&new_ellipse->center, "Center ",
- X+ &x1_panel, &y1_panel);
- X+ f_pos_panel(&new_ellipse->radiuses, "Radiuses",
- X+ &x2_panel, &y2_panel);
- X+ }
- X+ else {
- X+ f_pos_panel(&new_ellipse->center,"Center",
- X+ &x1_panel, &y1_panel);
- X+ int_panel(new_ellipse->radiuses.x, "Radius",
- X+ &x2_panel);
- X+ }
- X+ }
- X+
- X+ static
- X+ get_new_ellipse_values()
- X+ {
- X+ F_pos old_center;
- X+ F_pos old_radiuses;
- X+
- X+ # define adjust_ref(s,f) \
- X+ s.f = new_ellipse->center.f + \
- X+ ((s.f - old_center.f)*new_ellipse->radiuses.f)/old_radiuses.f
- X+
- X+ get_generic_vals(new_ellipse);
- X+ new_ellipse->angle = M_PI/180*atoi(panel_get_value(angle_panel));
- X+ old_center = new_ellipse->center;
- X+ old_radiuses = new_ellipse->radiuses;
- X+ get_f_pos(&new_ellipse->center, x1_panel, y1_panel);
- X+ if (ellipse_flag)
- X+ get_f_pos(&new_ellipse->radiuses, x2_panel, y2_panel);
- X+
- X+ else
- X+ new_ellipse->radiuses.x = new_ellipse->radiuses.y =
- X+ atoi(panel_get_value(x2_panel));
- X+
- X+ adjust_ref(new_ellipse->start, x);
- X+ adjust_ref(new_ellipse->start, y);
- X+ adjust_ref(new_ellipse->end, x);
- X+ adjust_ref(new_ellipse->end, y);
- X+ }
- X+
- X+ done_ellipse()
- X+ {
- X+ F_ellipse *old_ellipse;
- X+
- X+
- X+ draw_ellipse(new_ellipse, background_color);
- X+ old_ellipse = new_ellipse->next;
- X+ switch (button_result) {
- X+ case APPLY:
- X+ get_new_ellipse_values();
- X+ draw_ellipse(new_ellipse, foreground_color);
- X+ break;
- X+ case DONE:
- X+ clean_up();
- X+ get_new_ellipse_values();
- X+ set_action_object(F_CHANGE, O_ELLIPSE);
- X+ new_ellipse->next = NULL;
- X+ delete_ellipse(&objects.ellipses, old_ellipse);
- X+ insert_ellipse(&objects.ellipses, new_ellipse);
- X+ set_latestellipse(old_ellipse);
- X+ old_ellipse->next = new_ellipse;
- X+ draw_ellipse(new_ellipse, foreground_color);
- X+ show_pointmarker();
- X+ set_modifiedflag();
- X+ break;
- X+ case CANCEL:
- X+ clean_up();
- X+ new_ellipse->next = NULL;
- X+ free_ellipse(&new_ellipse);
- X+ draw_ellipse(old_ellipse, foreground_color);
- X+ show_pointmarker();
- X+ break;
- X+ }
- X+
- X+ }
- X+
- X+ make_window_arc(a)
- X+ F_arc *a;
- X+ {
- X+ new_arc = copy_arc(a);
- X+ new_arc->next = a;
- X+ put_generic_vals(new_arc);
- X+ put_generic_arrows(new_arc);
- X+ generic_window("ARC", "Specified by 3 points", done_arc, 1, 1);
- X+ f_pos_panel(&new_arc->point[0], "p1", &x1_panel, &y1_panel);
- X+ f_pos_panel(&new_arc->point[1], "p2", &x2_panel, &y2_panel);
- X+ f_pos_panel(&new_arc->point[2], "p3", &x3_panel, &y3_panel);
- X+ }
- X+
- X+ static
- X+ get_new_arc_values()
- X+ {
- X+ F_pos p0, p1, p2;
- X+ float cx, cy;
- X+
- X+ get_generic_vals(new_arc);
- X+ get_generic_arrows(new_arc);
- X+ get_f_pos(&p0, x1_panel, y1_panel);
- X+ get_f_pos(&p1, x2_panel, y2_panel);
- X+ get_f_pos(&p2, x3_panel, y3_panel);
- X+ if (compute_arccenter(p0, p1, p2, &cx, &cy)) {
- X+ new_arc->point[0] = p0;
- X+ new_arc->point[1] = p1;
- X+ new_arc->point[2] = p2;
- X+ new_arc->center.x = cx;
- X+ new_arc->center.y = cy;
- X+ new_arc->direction = compute_direction(p0, p1, p2);
- X+ }
- X+ else
- X+ put_msg("Invalid ARC points!");
- X+ }
- X+
- X+ done_arc()
- X+ {
- X+ F_arc *old_arc;
- X+
- X+
- X+ draw_arc(new_arc, background_color);
- X+ old_arc = new_arc->next;
- X+ switch (button_result) {
- X+ case APPLY:
- X+ get_new_arc_values();
- X+ draw_arc(new_arc, foreground_color);
- X+ break;
- X+ case DONE:
- X+ clean_up();
- X+ get_new_arc_values();
- X+ set_action_object(F_CHANGE, O_ARC);
- X+ new_arc->next = NULL;
- X+ delete_arc(&objects.arcs, old_arc);
- X+ insert_arc(&objects.arcs, new_arc);
- X+ set_latestarc(old_arc);
- X+ old_arc->next = new_arc;
- X+ draw_arc(new_arc, foreground_color);
- X+ show_pointmarker();
- X+ set_modifiedflag();
- X+ break;
- X+ case CANCEL:
- X+ clean_up();
- X+ new_arc->next = NULL;
- X+ free_arc(&new_arc);
- X+ draw_arc(old_arc, foreground_color);
- X+ show_pointmarker();
- X+ break;
- X+ }
- X+
- X+ }
- X+
- X+ make_window_spline(s)
- X+ F_spline *s;
- X+ {
- X+ new_spline = copy_spline(s);
- X+ new_spline->next = s;
- X+ put_generic_vals(new_spline);
- X+ put_generic_arrows(new_spline);
- X+ switch (new_spline->type) {
- X+ case T_OPEN_NORMAL:
- X+ generic_window("SPLINE", "Normal open", done_spline, 1, 1);
- X+ points_panel(new_spline->points, 0);
- X+ break;
- X+ case T_CLOSED_NORMAL:
- X+ generic_window("SPLINE", "Normal closed", done_spline, 1, 1);
- X+ points_panel(new_spline->points, 1);
- X+ break;
- X+ case T_OPEN_INTERPOLATED:
- X+ generic_window("SPLINE", "Interpolated open", done_spline, 1, 1);
- X+ points_panel(new_spline->points, 0);
- X+ break;
- X+ case T_CLOSED_INTERPOLATED:
- X+ generic_window("SPLINE","Interpolated closed",done_spline, 1,1);
- X+ points_panel(new_spline->points, 1);
- X+ break;
- X+ }
- X+ }
- X+
- X+ done_spline()
- X+ {
- X+ F_spline *old_spline;
- X+
- X+ draw_spline(new_spline, ERASE);
- X+ old_spline = new_spline->next;
- X+ switch (button_result) {
- X+ case APPLY:
- X+ get_generic_vals(new_spline);
- X+ get_generic_arrows(new_spline);
- X+ get_points(new_spline->points, closed_spline(new_spline));
- X+ if (int_spline(new_spline))
- X+ remake_control_points(new_spline);
- X+ draw_spline(new_spline, PAINT);
- X+ break;
- X+ case DONE:
- X+ clean_up();
- X+ get_generic_vals(new_spline);
- X+ get_generic_arrows(new_spline);
- X+ get_points(new_spline->points, closed_spline(new_spline));
- X+ set_action_object(F_CHANGE, O_SPLINE);
- X+ if (int_spline(new_spline))
- X+ remake_control_points(new_spline);
- X+ new_spline->next = NULL;
- X+ delete_spline(&objects.splines, old_spline);
- X+ insert_spline(&objects.splines, new_spline);
- X+ set_latestspline(old_spline);
- X+ old_spline->next = new_spline;
- X+ draw_spline(new_spline, PAINT);
- X+ show_pointmarker();
- X+ set_modifiedflag();
- X+ break;
- X+ case CANCEL:
- X+ clean_up();
- X+ new_spline->next = NULL;
- X+ free_spline(&new_spline);
- X+ draw_spline(old_spline, PAINT);
- X+ show_pointmarker();
- X+ break;
- X+ }
- X+ }
- X+
- X+
- X+ /*
- X+ * The following routines
- X+ * change_line, change_arc, change_ellipse, change_spline,
- X+ * change_text
- X+ * are called by the UNDO function (undo.c).
- X+ * saved_objects.xxxx contains a pointer to the original, unchanged version
- X+ * of the object. saved_objects.xxxx->next contains a pointer to the new,
- X+ * changed version of the object.
- X+ */
- X+
- X+ change_line(lold, lnew)
- X+ F_line *lold, *lnew;
- X+ {
- X+ lnew->next = NULL;
- X+ delete_line(&objects.lines, lold);
- X+ insert_line(&objects.lines, lnew);
- X+ set_latestline(lold);
- X+ lold->next = lnew;
- X+ draw_line(lold, ERASE);
- X+ draw_line(lnew, PAINT);
- X+ }
- X+
- X+ change_arc(aold, anew)
- X+ F_arc *aold, *anew;
- X+ {
- X+ anew->next = NULL;
- X+ delete_arc(&objects.arcs, aold);
- X+ insert_arc(&objects.arcs, anew);
- X+ set_latestarc(aold);
- X+ aold->next = anew;
- X+ draw_arc(aold, background_color);
- X+ draw_arc(anew, foreground_color);
- X+ }
- X+
- X+ change_ellipse(eold, enew)
- X+ F_ellipse *eold, *enew;
- X+ {
- X+ enew->next = NULL;
- X+ delete_ellipse(&objects.ellipses, eold);
- X+ insert_ellipse(&objects.ellipses, enew);
- X+ set_latestellipse(eold);
- X+ eold->next = enew;
- X+ draw_ellipse(eold, background_color);
- X+ draw_ellipse(enew, foreground_color);
- X+ }
- X+
- X+ change_spline(sold, snew)
- X+ F_spline *sold, *snew;
- X+ {
- X+ snew->next = NULL;
- X+ delete_spline(&objects.splines, sold);
- X+ insert_spline(&objects.splines, snew);
- X+ set_latestspline(sold);
- X+ sold->next = snew;
- X+ draw_spline(sold, ERASE);
- X+ draw_spline(snew, PAINT);
- X+ }
- X+
- X+ change_text(told, tnew)
- X+ F_text *told, *tnew;
- X+ {
- X+ tnew->next = NULL;
- X+ delete_text(&objects.texts, told);
- X+ insert_text(&objects.texts, tnew);
- X+ set_latesttext(told);
- X+ told->next = tnew;
- X+ draw_text(told, INV_PAINT);
- X+ draw_text(tnew, PAINT);
- X+ }
- X+
- X+
- X+ static void
- X+ new_generic_values()
- X+ {
- X+ int fill;
- X+ char buf[5];
- X+ char *val;
- X+
- X+ generic_vals.thickness = atoi(panel_get_value(thickness_panel));
- X+ generic_vals.color = atoi(panel_get_value(color_panel));
- X+ generic_vals.depth = atoi(panel_get_value(depth_panel));
- X+ if (!no_fill_flag)
- X+ {
- X+ val = panel_get_value(area_fill_panel);
- X+ if (*val >= ' ' && *val <= '9')
- X+ {
- X+ if ((fill = atoi(val)) > 100)
- X+ fill = 100;
- X+ generic_vals.area_fill = NUMFILLPATS - (fill / (100/(NUMFILLPATS-1)));
- X+ }
- X+ fill = (NUMFILLPATS - generic_vals.area_fill) * (100/(NUMFILLPATS-1));
- X+ panel_set_value(area_fill_panel, sprintf(buf,"%d",fill));
- X+ }
- X+ else
- X+ generic_vals.area_fill = 0;
- X+ }
- X+
- X+ static
- X+ new_arrow_values()
- X+ {
- X+ generic_vals.for_arrow = (int)panel_get_value(for_arrow_panel);
- X+ generic_vals.back_arrow = (int)panel_get_value(back_arrow_panel);
- X+ }
- X+
- X+ static char *
- X+ style_val_string(s, v)
- X+ int s;
- X+ double v;
- X+ {
- X+ static char buf[64];
- X+ switch(s) {
- X+ case SOLID_LINE:
- X+ return sprintf(buf, " ");
- X+ case DASH_LINE:
- X+ return sprintf(buf, "dash length = %3.1f", v);
- X+ case DOTTED_LINE:
- X+ return sprintf(buf, "dot gap = %3.1f", v);
- X+ }
- X+ return NULL;
- X+ }
- X+
- X+
- X+ static
- X+ done_button(panel_local,item, event)
- X+ Widget panel_local;
- X+ Widget *item;
- X+ int *event;
- X+ {
- X+ button_result = DONE;
- X+ done_proc();
- X+ Quit();
- X+ }
- X+
- X+ static
- X+ apply_button(panel_local,item, event)
- X+ Widget panel_local;
- X+ Widget *item;
- X+ int *event;
- X+ {
- X+ button_result = APPLY;
- X+ done_proc();
- X+ }
- X+
- X+ static
- X+ cancel_button(panel_local,item, event)
- X+ Widget panel_local;
- X+ Widget *item;
- X+ int *event;
- X+ {
- X+ button_result = CANCEL;
- X+ done_proc();
- X+ Quit();
- X+ }
- X+
- X+ static
- X+ generic_window(object_type, sub_type, d_proc, generics, arrows)
- X+ char *object_type, *sub_type;
- X+ int (*d_proc)();
- X+ int generics, arrows;
- X+ {
- X+ char buf[64];
- X+ Position x_val, y_val;
- X+ Dimension width, height;
- X+ Cardinal n;
- X+ int i, fill;
- X+
- X+ static char * menu_item_names[] = {
- X+ "Solid Line ", "Dashed Line", "Dotted Line"};
- X+
- X+ XtSetArg(args[0], XtNwidth, &width);
- X+ XtSetArg(args[1], XtNheight, &height);
- X+ XtGetValues(tool, args, TWO);
- X+ XtTranslateCoords(tool, (Position) (width / 2), (Position) (height / 5),
- X+ &x_val, &y_val);
- X+
- X+ n=0;
- X+ XtSetArg(args[n], XtNx, x_val); n++;
- X+ XtSetArg(args[n], XtNy, y_val); n++;
- X+
- X+ popup = XtCreatePopupShell("change", transientShellWidgetClass, tool,
- X+ args, n);
- X+
- X+ form = XtCreateManagedWidget("form", formWidgetClass, popup,NULL, 0);
- X+
- X+ done_proc = d_proc;
- X+
- X+ label = XtCreateManagedWidget(sprintf(buf,"%s:%s",object_type,
- X+ sub_type), labelWidgetClass, form, NULL, 0);
- X+ if (sub_type)
- X+ {
- X+ XtSetArg(args[0], XtNfromVert, label);
- X+ but1= XtCreateManagedWidget("done", commandWidgetClass, form, args, ONE);
- X+ XtAddCallback(but1, XtNcallback, done_button, NULL);
- X+ below = but1;
- X+ XtSetArg(args[0], XtNfromHoriz, but1);
- X+ XtSetArg(args[1], XtNfromVert,label);
- X+ but1= XtCreateManagedWidget("apply", commandWidgetClass, form, args, TWO);
- X+ XtAddCallback(but1, XtNcallback, apply_button, NULL);
- X+
- X+ XtSetArg(args[0], XtNfromHoriz, but1);
- X+ XtSetArg(args[1], XtNfromVert,label);
- X+ but1= XtCreateManagedWidget("cancel",commandWidgetClass, form, args, TWO);
- X+ XtAddCallback(but1, XtNcallback, cancel_button, NULL);
- X+
- X+
- X+ if (generics) {
- X+ int_panel(generic_vals.thickness, "Width:", &thickness_panel);
- X+ int_panel(generic_vals.color, "Color:", &color_panel);
- X+ int_panel(generic_vals.depth, "Depth:", &depth_panel);
- X+
- X+ if (generic_vals.area_fill == 0 ||
- X+ strcmp(sub_type,"Polyline") == 0) /* no area fill for polyline */
- X+ {
- X+ fill = 100;
- X+ no_fill_flag = TRUE;
- X+ }
- X+ else
- X+ {
- X+ fill = (NUMFILLPATS-generic_vals.area_fill) * (100/(NUMFILLPATS-1));
- X+ no_fill_flag = FALSE;
- X+ }
- X+
- X+ if (strcmp(sub_type,"Polyline") != 0) /* no area fill for polyline */
- X+ {
- X+ toggle_panel(no_fill_flag, no_fill_flag? "Not Filled": "Filled ",
- X+ &filled_panel);
- X+ int_panel(fill,"Fill%:", &area_fill_panel);
- X+ fill_pct_label = beside; /* save pointer to Fill% label */
- X+ XtSetArg(args[0], XtNsensitive, no_fill_flag? False: True);
- X+ XtSetValues(area_fill_panel, args, ONE);
- X+ XtSetValues(fill_pct_label, args, ONE);
- X+ if (no_fill_flag)
- X+ panel_set_value(area_fill_panel, " ");
- X+ else
- X+ panel_set_value(area_fill_panel, sprintf(buf,"%d",fill));
- X+ }
- X+
- X+ /* make popup line style menu */
- X+
- X+ XtSetArg(args[0], XtNfromVert, below);
- X+ style_panel = XtCreateManagedWidget(
- X+ menu_item_names[generic_vals.style], menuButtonWidgetClass,
- X+ form, args, ONE);
- X+ below = style_panel;
- X+ menu = make_popup_menu(menu_item_names, XtNumber(menu_item_names),
- X+ style_panel, line_style_select);
- X+ #ifdef notdef
- X+
- X+ }
- X+ if (arrows)
- X+ {
- X+ for_arrow_panel = panel_create_item(change_panel, PANEL_TOGGLE,
- X+ PANEL_LABEL_X, ATTR_COL(2),
- X+ PANEL_LABEL_Y, ATTR_ROW(10),
- X+ PANEL_VALUE_X, ATTR_COL(20),
- X+ PANEL_VALUE_Y, ATTR_ROW(10),
- X+ PANEL_LABEL_STRING, "Forward arrow:",
- X+ PANEL_VALUE, generic_vals.for_arrow,
- X+ PANEL_FEEDBACK, PANEL_MARKED,
- X+ PANEL_NOTIFY_PROC, new_arrow_values,
- X+ 0);
- X+ back_arrow_panel = panel_create_item(change_panel, PANEL_TOGGLE,
- X+ PANEL_LABEL_X, ATTR_COL(2),
- X+ PANEL_LABEL_Y, ATTR_ROW(11),
- X+ PANEL_VALUE_X, ATTR_COL(20),
- X+ PANEL_VALUE_Y, ATTR_ROW(11),
- X+ PANEL_LABEL_STRING, "Backward arrow:",
- X+ PANEL_VALUE, generic_vals.back_arrow,
- X+ PANEL_FEEDBACK, PANEL_MARKED,
- X+ PANEL_NOTIFY_PROC, new_arrow_values,
- X+ 0);
- X+ #endif /* not def */
- X+ }
- X+
- X+ }
- X+ }
- X+
- X+ /* make a button panel with the image 'pixmap' in it */
- X+ /* for the font selection */
- X+
- X+ void f_menu_popup();
- X+
- X+ static XtCallbackRec f_sel_callback[] =
- X+ {
- X+ { f_menu_popup, NULL },
- X+ { NULL, NULL },
- X+ };
- X+
- X+ static
- X+ image_panel(pixmap, label, pi_x)
- X+ Pixmap pixmap;
- X+ char *label;
- X+ Widget *pi_x;
- X+ {
- X+ char buf[32];
- X+
- X+ XtSetArg(args[0], XtNfromVert, below);
- X+ XtSetArg(args[1], XtNlabel, label);
- X+ below = XtCreateManagedWidget(label, labelWidgetClass, form, args, TWO);
- X+
- X+ XtSetArg(args[0], XtNfromVert, below);
- X+ XtSetArg(args[1], XtNbitmap, pixmap);
- X+ XtSetArg(args[2], XtNcallback, f_sel_callback);
- X+ *pi_x = XtCreateManagedWidget(label, commandWidgetClass, form, args, THREE);
- X+ below = *pi_x;
- X+ }
- X+
- X+ /* come here when user presses image button */
- X+
- X+ void
- X+ f_menu_popup()
- X+ {
- X+ font_sel = &new_font; /* store selected font number in new_font */
- X+ image_widget = font_panel; /* and image in this widget */
- X+ XtPopup(fontmenu,XtGrabNonexclusive); /* popup the font menu */
- X+ setup_fontmenu_cursor(); /* now define the cursor for the font menu */
- X+ }
- X+
- X+ /*
- X+ make a popup menu with "nent" button entries (labels) that call
- X+ "callback" when pressed
- X+ */
- X+
- X+ Widget
- X+ make_popup_menu(entries, nent, parent, callback)
- X+ char *entries[];
- X+ int nent;
- X+ Widget parent;
- X+ XtCallbackProc callback;
- X+ {
- X+ Widget pop_menu,entry;
- X+ int i;
- X+
- X+ pop_menu = XtCreatePopupShell("menu", simpleMenuWidgetClass, parent,
- X+ NULL, ZERO);
- X+
- X+ for (i = 0; i < nent ; i++)
- X+ {
- X+ entry = XtCreateManagedWidget(entries[i], smeBSBObjectClass, pop_menu,
- X+ NULL, ZERO);
- X+ XtAddCallback(entry, XtNcallback, callback, (XtPointer) i);
- X+ }
- X+ return pop_menu;
- X+ }
- X+
- X+ static
- X+ int_panel(x, label, pi_x)
- X+ int x;
- X+ char *label;
- X+ Widget *pi_x;
- X+ {
- X+ char buf[32];
- X+
- X+ XtSetArg(args[0], XtNfromVert, below);
- X+ XtSetArg(args[1], XtNlabel, label);
- X+ beside = XtCreateManagedWidget(label, labelWidgetClass, form, args, TWO);
- X+
- X+ XtSetArg(args[1], XtNstring, sprintf(buf, "%d", x));
- X+ XtSetArg(args[2], XtNinsertPosition, strlen(buf));
- X+ XtSetArg(args[3], XtNfromHoriz, beside);
- X+ XtSetArg(args[4], XtNeditType, "append");
- X+ XtSetArg(args[5], XtNwidth, 40);
- X+ *pi_x = XtCreateManagedWidget(label, asciiTextWidgetClass, form, args, SIX);
- X+ below = *pi_x;
- X+ }
- X+
- X+ /* don't allow newlines in text until we handle multiple line texts */
- X+
- X+ static String text_translations =
- X+ "<Key>Return: no-op(RingBell)\n\
- X+ Ctrl<Key>J: no-op(RingBell)\n\
- X+ Ctrl<Key>M: no-op(RingBell)\n";
- X+
- X+ static
- X+ str_panel(string, label, pi_x)
- X+ char *string;
- X+ char *label;
- X+ Widget *pi_x;
- X+ {
- X+ int width,nlines,i,n;
- X+ Dimension pwidth;
- X+ PIX_FONT temp_font;
- X+
- X+ XtSetArg(args[0], XtNfromVert, below);
- X+ XtSetArg(args[1], XtNlabel, label);
- X+ beside = XtCreateManagedWidget(label, labelWidgetClass, form, args, TWO);
- X+
- X+ /* get the font and width of above label widget */
- X+ n=0;
- X+ XtSetArg(args[n], XtNfont, &temp_font); n++;
- X+ XtSetArg(args[n], XtNwidth, &pwidth); n++;
- X+ XtGetValues(beside, args, n);
- X+ /* make panel as wide as image pane above less the label widget's width */
- X+ /* but at least 200 pixels wide */
- X+ width = max(FONT_PANE_WIDTH-pwidth+2, 200);
- X+
- X+ /* count number of lines in this text string */
- X+ nlines=1; /* number of lines in string */
- X+ for (i=0; i<strlen(string); i++)
- X+ {
- X+ if (string[i]=='\n')
- X+ {
- X+ nlines++;
- X+ }
- X+ }
- X+ if (nlines > 6) /* limit to displaying 6 lines and show scrollbars */
- X+ nlines=6;
- X+ n=0;
- X+ XtSetArg(args[n], XtNfromVert, below); n++;
- X+ XtSetArg(args[n], XtNstring, string); n++;
- X+ XtSetArg(args[n], XtNinsertPosition, strlen(string)); n++;
- X+ XtSetArg(args[n], XtNfromHoriz, beside); n++;
- X+ XtSetArg(args[n], XtNeditType, "edit"); n++;
- X+ XtSetArg(args[n], XtNwidth, width); n++;
- X+ XtSetArg(args[n], XtNheight, char_height(temp_font)*nlines+4); n++;
- X+ XtSetArg(args[n], XtNscrollHorizontal, XawtextScrollWhenNeeded);n++;
- X+ XtSetArg(args[n], XtNscrollVertical, XawtextScrollWhenNeeded); n++;
- X+ *pi_x = XtCreateManagedWidget(label, asciiTextWidgetClass, form, args, n);
- X+
- X+ /* make Newline do nothing for now */
- X+ XtOverrideTranslations(*pi_x,XtParseTranslationTable(text_translations));
- X+
- X+ below = *pi_x;
- X+ }
- X+
- X+ static
- X+ toggle_panel(x, label, pi_x)
- X+ int x;
- X+ char *label;
- X+ Widget *pi_x;
- X+ {
- X+ XtSetArg(args[0], XtNfromVert, below);
- X+ XtSetArg(args[1], XtNlabel, label);
- X+ XtSetArg(args[2], XtNvalue, x);
- X+ *pi_x = XtCreateManagedWidget(label, toggleWidgetClass, form, args, THREE);
- X+ XtAddCallback(*pi_x, XtNcallback, toggle, NULL);
- X+ below = *pi_x;
- X+ }
- X+
- X+ static
- X+ xy_panel(x, y, label, pi_x, pi_y)
- X+ int x, y;
- X+ char *label;
- X+ Widget *pi_x, *pi_y;
- X+ {
- X+ char buf[32];
- X+
- X+ XtSetArg(args[0], XtNfromVert, below);
- X+ XtSetArg(args[1], XtNlabel, label);
- X+ below = XtCreateManagedWidget(label, labelWidgetClass, form, args, TWO);
- X+ XtSetArg(args[0], XtNfromVert, below);
- X+ XtSetArg(args[1], XtNlabel, "X:");
- X+ beside = XtCreateManagedWidget(label, labelWidgetClass, form, args, TWO);
- X+
- X+ XtSetArg(args[1], XtNstring, sprintf(buf, "%d", x));
- X+ XtSetArg(args[2], XtNinsertPosition, strlen(buf));
- X+ XtSetArg(args[3], XtNfromHoriz, beside);
- X+ XtSetArg(args[4], XtNeditType, "append");
- X+ XtSetArg(args[5], XtNwidth, 40);
- X+ *pi_x = XtCreateManagedWidget(label, asciiTextWidgetClass, form, args, SIX);
- X+
- X+ XtSetArg(args[1], XtNlabel, "Y:");
- X+ XtSetArg(args[2], XtNfromHoriz, *pi_x);
- X+ beside = XtCreateManagedWidget(label, labelWidgetClass, form, args, THREE);
- X+
- X+ XtSetArg(args[1], XtNstring, sprintf(buf, "%d", y));
- X+ XtSetArg(args[2], XtNfromHoriz, beside);
- X+ XtSetArg(args[3], XtNinsertPosition, strlen(buf));
- X+ XtSetArg(args[4], XtNeditType, "append");
- X+ XtSetArg(args[5], XtNwidth, 40);
- X+ *pi_y = XtCreateManagedWidget(label, asciiTextWidgetClass, form, args ,SIX);
- X+
- X+ below = *pi_x;
- X+ }
- X+
- X+ static
- X+ f_pos_panel(fp, label, pi_x, pi_y)
- X+ F_pos *fp;
- X+ char *label;
- X+ Widget *pi_x, *pi_y;
- X+ {
- X+ char buf[32];
- X+
- X+ XtSetArg(args[0], XtNfromVert, below);
- X+ below = XtCreateManagedWidget(label, labelWidgetClass, form, args, ONE);
- X+ XtSetArg(args[0], XtNfromVert, below);
- X+ XtSetArg(args[1], XtNlabel, "X:");
- X+ beside = XtCreateManagedWidget(label, labelWidgetClass, form, args, TWO);
- X+ XtSetArg(args[1], XtNstring, sprintf(buf, "%d", fp->x));
- X+ XtSetArg(args[2], XtNinsertPosition, strlen(buf));
- X+ XtSetArg(args[3], XtNfromHoriz, beside);
- X+ XtSetArg(args[4], XtNeditType, "append");
- X+ XtSetArg(args[5], XtNwidth, 40);
- X+ *pi_x = XtCreateManagedWidget(label, asciiTextWidgetClass, form, args, SIX);
- X+ XtSetArg(args[1], XtNlabel, "Y:");
- X+ XtSetArg(args[2], XtNfromHoriz, *pi_x);
- X+ beside = XtCreateManagedWidget(label, labelWidgetClass, form, args, THREE);
- X+ XtSetArg(args[1], XtNstring, sprintf(buf, "%d", fp->y));
- X+ XtSetArg(args[2], XtNinsertPosition, strlen(buf));
- X+ XtSetArg(args[3], XtNfromHoriz, beside);
- X+ XtSetArg(args[4], XtNeditType, "append");
- X+ XtSetArg(args[5], XtNwidth, 40);
- X+ *pi_y = XtCreateManagedWidget(label, asciiTextWidgetClass, form, args ,SIX);
- X+ below = *pi_x;
- X+ }
- X+
- X+ static
- X+ get_f_pos(fp, pi_x, pi_y)
- X+ F_pos *fp;
- X+ Widget pi_x, pi_y;
- X+ {
- X+ fp->x = (atoi(panel_get_value(pi_x)));
- X+ fp->y = (atoi(panel_get_value(pi_y)));
- X+ }
- X+
- X+ static
- X+ points_panel(p, closed)
- X+ struct f_point *p;
- X+ int closed;
- X+ {
- X+ char buf[32];
- X+ char bufxy[32];
- X+ int i;
- X+
- X+ for (i = 0; p != NULL; i++) {
- X+ if (i >= MAX_POINTS)
- X+ break;
- X+ XtSetArg(args[0], XtNfromVert,below);
- X+ XtSetArg(args[1], XtNlabel, sprintf(buf,"X:%d",i));
- X+ beside = XtCreateManagedWidget(label, labelWidgetClass, form, args, TWO);
- X+ XtSetArg(args[1], XtNstring, sprintf(bufxy, "%d", (p->x)));
- X+ XtSetArg(args[2], XtNinsertPosition, strlen(bufxy));
- X+ XtSetArg(args[3], XtNfromHoriz, beside);
- X+ XtSetArg(args[4], XtNeditType, "append");
- X+ XtSetArg(args[5], XtNwidth, 40);
- X+ px_panel[i] = XtCreateManagedWidget("xy", asciiTextWidgetClass,
- X+ form, args, SIX);
- X+
- X+ XtSetArg(args[1], XtNlabel, sprintf(buf,"Y:%d",i));
- X+ XtSetArg(args[2], XtNfromHoriz, px_panel[i]);
- X+ beside = XtCreateManagedWidget(label, labelWidgetClass,
- X+ form, args, THREE);
- X+
- X+ XtSetArg(args[1], XtNstring, sprintf(bufxy, "%d",(p->y)));
- X+ XtSetArg(args[2], XtNinsertPosition, strlen(bufxy));
- X+ XtSetArg(args[3], XtNfromHoriz,beside);
- X+ XtSetArg(args[4], XtNeditType, "append");
- X+ XtSetArg(args[5], XtNwidth, 40);
- X+
- X+ py_panel[i] = XtCreateManagedWidget("xy", asciiTextWidgetClass,
- X+ form, args, SIX);
- X+ below = px_panel[i];
- X+
- X+ p = p->next;
- X+ if (closed && (p == NULL || p->next == NULL))
- X+ break;
- X+
- X+
- X+ }
- X+ }
- X+
- X+ static
- X+ get_points(p, closed)
- X+ struct f_point *p;
- X+ {
- X+ struct f_point *q;
- X+ int i;
- X+
- X+ for (q = p, i = 0; q != NULL; i++) {
- X+ if (i >= MAX_POINTS)
- X+ break;
- X+ q->x = (atoi(panel_get_value(px_panel[i])));
- X+ q->y = (atoi(panel_get_value(py_panel[i])));
- X+ q = q->next;
- X+ if (closed) {
- X+ if (q == NULL)
- X+ break;
- X+ else if (q->next == NULL) {
- X+ q->x = p->x;
- X+ q->y = p->y;
- X+ break;
- X+ }
- X+ }
- X+ }
- X+ }
- X+
- X+
- X+ void
- X+ Quit(widget, client_data, call_data)
- X+ Widget widget;
- X+ XtPointer client_data, call_data;
- X+ {
- X+
- X+ XtDestroyWidget(popup);
- X+ }
- X+
- X+ char *
- X+ panel_get_value(widg)
- X+ Widget widg;
- X+ {
- X+ char *val;
- X+
- X+ XtSetArg(args[0], XtNstring, &val);
- X+ XtGetValues(widg, args, ONE);
- X+ if(atol(val) < 0)
- X+ {
- X+ panel_set_value(widg,"0");
- X+ return "0";
- X+ }
- X+ return val;
- X+
- X+ }
- X+
- X+
- X+ panel_set_value(widg, val)
- X+ Widget widg;
- X+ char *val;
- X+ {
- X+
- X+ XtSetArg(args[0], XtNstring, val);
- X+ XtSetValues(widg, args, ONE);
- X+ XtSetArg(args[0], XtNinsertPosition, strlen(val));
- X+ XtSetValues(widg, args, ONE);
- X+ }
- X+
- X+
- X+ static void
- X+ line_style_select(w, style, garbage)
- X+ Widget w;
- X+ XtPointer style, garbage;
- X+ {
- X+
- X+ XtSetArg(args[0], XtNlabel, XtName(w));
- X+ XtSetValues(style_panel, args, ONE);
- X+
- X+ generic_vals.style = (int) style;
- X+
- X+ switch(generic_vals.style)
- X+ {
- X+ case SOLID_LINE:
- X+ generic_vals.style_val = 0.0;
- X+ break;
- X+ case DASH_LINE:
- X+ generic_vals.style_val = cur_dashlength;
- X+ break;
- X+ case DOTTED_LINE:
- X+ generic_vals.style_val = cur_dotgap;
- X+ break;
- X+ }
- X+ }
- X+
- X+ static void
- X+ text_adjust_select(w, adjust, garbage)
- X+ Widget w;
- X+ XtPointer adjust, garbage;
- X+ {
- X+
- X+ XtSetArg(args[0], XtNlabel, XtName(w));
- X+ XtSetValues(adjust_panel, args, ONE);
- X+ text_adjust = (int) adjust;
- X+ }
- X+
- X+
- X+ void
- X+ toggle(w, clos, garbage)
- X+ Widget w;
- X+ XtPointer clos, garbage;
- X+ {
- X+ char buf[5];
- X+ int fill;
- X+
- X+ if(no_fill_flag == TRUE)
- X+ no_fill_flag = FALSE;
- X+ else
- X+ no_fill_flag = TRUE;
- X+
- X+ /* set label to reflect fill flag */
- X+ XtSetArg(args[0], XtNlabel, no_fill_flag? "Not Filled": "Filled ");
- X+ XtSetValues(w, args, ONE);
- X+
- X+ /* make fill% panel sensitive or insensitive depending on fill flag */
- X+ XtSetArg(args[0], XtNsensitive, no_fill_flag? False: True);
- X+ XtSetValues(area_fill_panel, args, ONE);
- X+ XtSetValues(fill_pct_label, args, ONE);
- X+ fill = (NUMFILLPATS - generic_vals.area_fill) * (100/(NUMFILLPATS-1));
- X+ if (fill > 100)
- X+ fill = 100;
- X+ if (no_fill_flag)
- X+ panel_set_value(area_fill_panel, " ");
- X+ else
- X+ panel_set_value(area_fill_panel, sprintf(buf,"%d",fill));
- X+ }
- END_OF_FILE
- if test 39291 -ne `wc -c <'change.c.diff'`; then
- echo shar: \"'change.c.diff'\" unpacked with wrong size!
- fi
- # end of 'change.c.diff'
- fi
- echo shar: End of archive 6 \(of 6\).
- cp /dev/null ark6isdone
- MISSING=""
- for I in 1 2 3 4 5 6 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 6 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
- dan
- -----------------------------------------------------------
- O'Reilly && Associates
- argv@sun.com / argv@ora.com
- 632 Petaluma Ave, Sebastopol, CA 95472
- 800-338-NUTS, in CA: 800-533-NUTS, FAX 707-829-0104
- Opinions expressed reflect those of the author only.
-